﻿@{
    ViewBag.Title = "成果库列表";
}
<!--Banner-->
@section LayoutHeadContainer{
<link href="/css/facebox.css" media="screen" rel="stylesheet" type="text/css" />
<script src="/scripts/facebox.js" type="text/javascript"></script>
<script>
    $(function () {
        $(".btn").button();
    });
</script>
}
<!--Middle section-->
<div id="middle-sdo1">
  <div id="middle">
    <!--Message-->
    <div class="message">北京电力工程公司成果库系统欢迎您！</div>
    <table width="100%">
        <tr>
            <td style=" width:150px; vertical-align:middle"><span style=" padding-left:5px; padding-right:10px;">@Html.TextBox("txtSearch", "姓名/登录名", new { maxlength = "20", style = "color:#AAAAAA", value = "姓名/登录名", onfocus = "if (value=='姓名/登录名'){value ='';this.style.color='#000000'}", onblur = "if (value==''){value='姓名/登录名';this.style.color='#AAAAAA'}" })</span></td>
            <td style=" width:100px"><button id="btnSearch" class="btn" onclick="gridReload();">搜索</button></td>
            <td style="text-align:right;padding-bottom:5px">
                @if(Achievement.Web.Common.UserInfo.ValidataRole(1)){
                <button id="uploadfile" class="btn" onclick="window.location.href='/users/edituser'">添加用户</button>
                }
            </td>
        </tr>
    </table> 
    <div class="clearfix"> </div>
    <div style="text-align:center"><table id="list2" style="margin:auto"></table></div>
        <div id="pager2"></div>
  </div>
</div>
<script>
$.jgrid.ajaxOptions.type = 'post';
    $("#list2").jqGrid({
        url: '/users/list',
        datatype: "json",
        mtype: "POST",
        colNames: ['ID', '姓名', '登录名', '工号', '参加工作时间', '职务','所在部门','审核状态', '操作'],
        colModel: [
            { name: 'ID', index: 'ID', width: 55, classes: 'myjqgrid', hidden: true },
   		    { name: 'Name', index: 'Name', width: 55, editable: true, editoptions: { size: 10} },
   		    { name: 'LoginName', index: 'LoginName', width: 90 },
            { name: 'WorkNumber', index: 'WorkNumber', width: 90 },
            { name: 'WorkData', index: 'WorkData', width: 90 },
            { name: 'Position', index: 'Position', width: 90 },
            { name: 'Department', index: 'Department', width: 90 },
            { name: 'IsActive', index: 'IsActive', width: 90, hidden: true},
            { name: 'Operat', index: 'Operat', width: 90,align:"center"@(!Achievement.Web.Common.UserInfo.ValidataRole(1)?",hidden: true":"")},
   	    ],
        rowNum: 10,
        rowList: [10, 20, 30],
        pager: '#pager2',
        sortname: 'ID',
        viewrecords: true,
        sortorder: "desc",
        caption: "用户列表",
        autowidth: true,
        shrinkToFit: true,
        multiselect: true,
        height: 'auto',
        emptyrecords: "暂无数据",
        editurl: "someurl.php",
        pgtext:'第{0}页 共{1}页',
	    recordtext:'第 {0} - {1}条记录 '
    });
    jQuery("#list2").jqGrid('navGrid', '#pager2', { edit: false, add: false, del: false,position:false,
        addfunc: function () {
            $.facebox({ ajax: '/users/getAuthority?id=1' });
        },
        editfunc: function () {
            $.facebox({ ajax: '/users/getAuthority?id=1' });
        },
        delfunc: function () {
            $.facebox({ ajax: '/users/getAuthority?id=1' });
        },
        //alerttext: '请选择您要做操的列！',
        //alertcap: "提示"
    },
    {
        addCaption: "Add Record",
        editCaption: "修改",
        bSubmit: "提交",
        bCancel: "取消",
        bClose: "Close",
        saveData: "Data has been changed! Save changes?",
        bYes: "Yes",
        bNo: "No",
        bExit: "Cancel"
    });
    $("#bedata").click(function () {
        var gr = jQuery("#editgrid").jqGrid('getGridParam', 'selrow');
        if (gr != null) jQuery("#editgrid").jqGrid('editGridRow', gr, { height: 280, reloadAfterSubmit: false });
        else alert("Please Select Row");
    });

    function gridReload(){
	    var nm_mask = jQuery("#item_nm").val();
	    var cd_mask = jQuery("#search_cd").val();
	    jQuery("#list2").jqGrid('setGridParam', { url: "/users/list",postData:{where:$("#txtSearch").val().replace('姓名/登录名', '')},mtype: "POST", page: 1 }).trigger("reloadGrid");
    }

    function OperatFunc(cellvalue, options, rowdata)
    {
    }
    function deleteuser(id) {
        if (confirm("删除操作不可逆，您确认删除吗？")) {
            window.location.href = "/users/delete?id=" + id;
        }
    }

    function UserAuditing(id) {
        if (confirm("是否审核通过？")) {
            window.location.href = "/users/UserAuditing?id=" + id;
        }
    }
</script>